package com.ms.game.bank.db;

import com.ms.game.bank.message.BankResponse;
import com.ms.player.Player;
import com.ms.service.error.ErrorCode;
import com.ms.service.module.datacenterlite.CentralAsyncCommand;
import com.xpec.c4.game.utility.GUID;
import com.xpec.c4.service.message.MessageAction;

public class loadAccountCashDCLAsync extends CentralAsyncCommand {

	private static final long serialVersionUID = -11513285855446447L;
	
	public GUID accountID;
	
	public GUID playerID;
	
	public GUID sessionID;
	
	private long afterAccountCash = 0;
	
	private int errorCode = ErrorCode.SUCCESS;

	@Override
	public void asyncExecute() throws Exception {
		// TODO kevin loadAccountCash [v] unuse
		Object[] cashOb = BankDAO.loadAccountCashPoint(accountID);
		
		if (cashOb == null) {
			errorCode = ErrorCode.DB_OPERATION_FAIL;
		} else {
			afterAccountCash = (long) cashOb[0];
		}
	}

	@Override
	public void callBackExecute(Object... userData) throws Exception {
		Player playerData = (Player)userData[0];
		int messageType = (int)userData[1];
		
		BankResponse response = new BankResponse();
		response.bankGold = playerData.getBankGoldCoin().toString();
		response.vip = playerData.getVip();
		response.vipExp = playerData.getVipExp();
		response.accountCashPoint = afterAccountCash;
		response.monthlyFeeEndTime = playerData.getMonthlyFeeEndTime();
		response.errorCode = errorCode;
		MessageAction.sendMessage(sessionID, messageType, response);

	}

}
